import { Injectable } from '@nestjs/common';
import { DbService } from '../db/db.service';
import { CachingService } from '../caching/caching.service';

@Injectable()
export class UserService {
    private readonly prefix = 'user:';

    constructor(
        private readonly db:DbService,
        private readonly cache:CachingService
    ) {}

    setCache(id:number, user:any) {
        return this.cache.hmset(this.prefix + id, user)
    }

    getFromCache(id:number) {
        return this.cache.hgetall(this.prefix + id)
    }
}
